package com.zut.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.zut.dao.HouseDao;
import com.zut.dao.impl.HouseDaoImpl;
import com.zut.entity.House;
import com.zut.service.HouseService;
import com.zut.utils.LimitUtil;

public class HouseServiceImpl implements HouseService{

	HouseDao houseDao = new HouseDaoImpl();
	@Override
	public LimitUtil getData(int currentPage) {
		LimitUtil limitUtil = new LimitUtil();
		int m = (currentPage-1)*limitUtil.getPageSize();
		int n = limitUtil.getPageSize();
		List<House> houses = houseDao.quaryAll(m, n);
		limitUtil.setData(houses);
		limitUtil.setCurrentPage(currentPage);
		int num = houseDao.getTotalCount();
		limitUtil.setTotalCount(num);
		return limitUtil; 
	}
	@Override
	public House queryById(int h_id) {
		return houseDao.queryById(h_id);
	}
	@Override
	public void addHouse(House house) {
		houseDao.addHouse(house);
		
	}
	@Override
	public void deleteHouse(int h_id) {
		houseDao.deleteHouse(h_id);
		
	}
	@Override
	public void updateHouse(House house) {
		houseDao.updateHouse(house);
		
	}

}
